<template>
  <div class="data-tabs">
    <el-row :span="24">
      <el-col :span="span" v-for="(item, index) in data" :key="index">
        <div class="item" :style="{ background: item.color }">
          <div class="item-header">
            <p>{{ item.title }}</p>
            <span>{{ item.subtitle }}</span>
          </div>
          <div class="item-body">
            <h2>
              <CountTo
                :start-val="0"
                :end-val="item.count"
                :duration="3600"
                class="card-panel-num"
              />
            </h2>
          </div>
          <div class="item-footer">
            <span>{{ item.allcount }}</span>
            <p>{{ item.text }}</p>
          </div>
          <p class="item-tip">{{ item.key }}</p>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import CountTo from "vue-count-to";
export default {
  components: {
    CountTo,
  },
  name: "nx-data-tabs",
  data() {
    return {
      span: this.option.span || 6,
      data: this.option.data || [],
    };
  },
  props: {
    option: {
      type: Object,
      default: () => {},
    },
  },
};
</script>

<style lang="less" scoped>
.data-tabs {
  .item {
    position: relative;
    margin-right: 20px;
    padding: 12px;
    border-radius: 4px;
    box-sizing: border-box;
    overflow: hidden;
    color: #fff;
  }
  .el-col:last-child {
    .item {
      margin-right: 0;
    }
  }
  .item-header {
    position: relative;
    & > p {
      margin: 0px;
      font-size: @size18;
    }
    & > span {
      position: absolute;
      right: 0px;
      top: 0px;
      padding: 2px 8px;
      border-radius: 4px;
      font-size: @size16;
      background: rgba(255, 255, 255, 0.3);
    }
  }
  .item-body {
    & > h2 {
      margin: 0;
      font-size: 32px;
      line-height: 60px;
    }
  }
  .item-footer {
    line-height: 16px;
    & > span {
      font-size: 10px;
    }
    & > p {
      margin: 0px;
      font-size: @size16;
    }
  }
  .item-tip {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    width: 80px;
    height: 80px;
    bottom: 10px;
    right: 10px;
    border: 2px solid #fff;
    border-radius: 100%;
    font-size: 48px;
    transform: rotate(-40deg);
    opacity: 0.1;
  }
}
</style>
